//
//  ExamTimeCountDownView.m
//  JPWords
//
//  Created by 梁淑婷 on 2024/6/6.
//

#import "ExamTimeCountDownView.h"

@interface ExamTimeCountDownView()

@property(nonatomic,strong)UILabel *hourLabel;
@property(nonatomic,strong)UILabel *minuteLabel;

@end

@implementation ExamTimeCountDownView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if(self){
        [self createUI];
    }
    return self;
}

-(void)createUI{
    
    self.backgroundColor = [UIColor whiteColor];
    
    self.hourLabel = [[UILabel alloc]init];
    self.hourLabel.font = JPUIFontInterMedium(13);
    self.hourLabel.textColor = KFontBlackColor;
    self.hourLabel.textAlignment = NSTextAlignmentCenter;
    self.hourLabel.text = @"00";
    self.hourLabel.layer.cornerRadius = 6;
    self.hourLabel.layer.masksToBounds = YES;
    self.hourLabel.layer.borderWidth = 1.0;
    self.hourLabel.layer.borderColor = UIColorHex(0xEBF0EF).CGColor;
    [self addSubview:self.hourLabel];
    [self.hourLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(@24);
        make.left.top.mas_equalTo(@0);
    }];
    
    __weak typeof(self)self_weak_ = self;
    UILabel *centerLabel = [[UILabel alloc]init];
    centerLabel.font = JPUIFontInterMedium(15);
    centerLabel.textColor = KFontBlackColor;
    centerLabel.textAlignment = NSTextAlignmentCenter;
    centerLabel.text = @":";
    [self addSubview:centerLabel];
    [centerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(@15);
        make.centerX.mas_equalTo(self_weak_);
        make.top.mas_equalTo(@-2);
        make.height.mas_equalTo(@24);
    }];
    
    self.minuteLabel = [[UILabel alloc]init];
    self.minuteLabel.font = JPUIFontInterMedium(13);
    self.minuteLabel.textColor = KFontBlackColor;
    self.minuteLabel.textAlignment = NSTextAlignmentCenter;
    self.minuteLabel.text = @"00";
    self.minuteLabel.layer.cornerRadius = 6;
    self.minuteLabel.layer.masksToBounds = YES;
    self.minuteLabel.layer.borderWidth = 1.0;
    self.minuteLabel.layer.borderColor = UIColorHex(0xEBF0EF).CGColor;
    [self addSubview:self.minuteLabel];
    [self.minuteLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(@24);
        make.right.top.mas_equalTo(@0);
    }];
}

-(void)refreshWithHour:(NSString*)hour andMinute:(NSString *)minute{
    self.hourLabel.text = hour;
    self.minuteLabel.text = minute;
}

@end
